package com.cskaoyan.controller.backgroundsystemcontroller;

import com.cskaoyan.bean.bo.GoodsCommentDeleteBo;
import com.cskaoyan.bean.bo.GoodsCommentListBo;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.GoodsCommentListVo;
import com.cskaoyan.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**商品评论
 * @author 杨丰韶
 * @class GoodsCommentController
 */
@RestController
@RequestMapping("admin/comment")
public class GoodsCommentController {
    @Autowired
    private GoodsService goodsService;

    @GetMapping("list")
    public BaseRespVo commentList(GoodsCommentListBo listBo){
        GoodsCommentListVo data = goodsService.queryGoodsCommentList(listBo);
        return BaseRespVo.ok(data);
    }

    @PostMapping("delete")
    public BaseRespVo commentDelete(@RequestBody GoodsCommentDeleteBo goodsCommentDeleteBo){
        Integer result = goodsService.removeGoodsComment(goodsCommentDeleteBo.getId());
        if (result==200){
            return BaseRespVo.ok();
        }
        return BaseRespVo.fail("删除失败，该评论不存在或者已经被删除");
    }

}
